<template>
  <van-nav-bar
    :title="title"
    @click-left="onClickLeft"
    @click-right="onClickRight"
  >
    <template #left v-if="show">
      <van-icon name="arrow-left" size="30" />
      <span style="color: #1989fa">返回</span>
    </template>

    <template #right>
      <van-icon name="more" size="26" />
      <van-popover
        class="mypop"
        placement="bottom-end"
        v-model="showPopover"
        trigger="click"
        @select="clickOneDone"
        :actions="actions"
      >
        <template #reference>
          <!-- <van-icon name="more" size="26" /> -->
        </template>
      </van-popover>
    </template>
  </van-nav-bar>
</template>


<script>
export default {
  props: {
    title: String,
    show: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      showPopover: false,
      actions: [
        {
          text: "搜索",
          icon: "search",
          name: "search",
        },
        {
          text: "登录",
          icon: "friends-o",
          name: "login",
        },
        {
          text: "拍照",
          icon: "video-o",
          name: "photo",
        },
      ],
    };
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    onClickRight() {
      this.showPopover = true;
    },
    clickOneDone(action, index) {
      if (this.$route.name != action.name) {
        this.$router.push({
          name: action.name,
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>

// .van-nav-bar{
//   position: fixed;
//   top: 0;
//   left: 0;
//   width: 100%;
//   height: 100%;
// }
</style>